<?php
//从数据库拿到数据
//1.连接数据库
include('connect.php');
//2.获取所有商品信息
//$sql = "SELECT * FROM `scenics`";
//$res = mysqli_query($link,$sql);
//3.查询操作需要解析结果集
//$row = mysqli_fetch_assoc($res);
//结果很多，需要循环
//$arr = [];
//while($row==$res){
    //$arr = $row;//结果放入数组
//}
//返回对象
//echo json_encode([
    //'meta'=>['status'=>0,'msg'=>'数据获取成功'],
    //'data'=>$arr
//]);
//echo json_encode($row);
// 获取所有的景点信息
$res = mysqli_query($link,"select * from scenics");
$arr = [];
while($row = mysqli_fetch_assoc($res)){
    $arr[] = $row;
}
echo json_encode([
    "meta"=>[
        "status"=>0,
        "msg"=>"数据获取成功"
    ],
    "data"=>$arr
]);
?>